/**
 * Created by sunzhijun on 2019/02/19.
 */
import React, {Component} from 'react';
import Pagination from 'src/hrpub/common/components/Pagination';

class PaginationSign extends Component{
    constructor(props){
        super(props);
        this.state = {
            
        }
    }

    //列表翻页事件
    changePaginationFn(pageIndex){
        let pageInfo = this.props.pageInfo;
        pageInfo.pageIndex = pageIndex;
        this.props.changePagination && this.props.changePagination(pageInfo);
    }

    // 每页显示条数
    pageSizeSelect (val) {
        let pageInfo = this.props.pageInfo;
        pageInfo.pageSize = val;
        this.props.pageSizeSelect && this.props.pageSizeSelect(pageInfo);
    }

    render(){
        // if(!!this.props.pageInfo){
            let { pageInfo, isVisiblePagination } = this.props;
        // }else{
        //     var { pageInfo, isVisiblePagination } = this.state;
        // }
        return (
            isVisiblePagination ?
            <div className="pagination">
                <Pagination
                    // current = {pageInfo.pageIndex}
                    // hideOnSinglePage = {true}
                    showSizeChanger = {true}
                    current = {pageInfo.pageIndex * 1}
                    pageSize = {pageInfo.pageSize}
                    showQuickJumper = {true}
                    total = {pageInfo.total}
                    onChange= {this.changePaginationFn.bind(this)}
                    onShowSizeChange = {this.pageSizeSelect.bind(this)}
                />
            </div> : ''
        )
    }
}

PaginationSign.defaultProps={
    pageInfo: {
        current : 1,
        pageSize: 10,
        total : 0,
        pageIndex: 1
    }
}

export default PaginationSign;